﻿Public Class CLSCestas
    Dim sql As String
    Dim objbanco As New CLSBanco
    Dim objCP As New CLSCestaProdutos
    Dim M_Ces_ID As Integer
    Dim M_Ces_Nom As String


    Public Property ID() As Integer
        Get
            Return M_Ces_ID
        End Get
        Set(ByVal value As Integer)
            M_Ces_ID = value
        End Set
    End Property

    Public Property Nome() As String
        Get
            Return M_Ces_Nom
        End Get
        Set(ByVal value As String)
            M_Ces_Nom = value
        End Set
    End Property

    Public Sub Gravar()

        Try
            sql = "insert into Cestas " & _
              "(Cli_Nom" & _
              ",CP_idCesta" & _
              ",CP_idPro" & _
              ",CP_qtd" & _
              ",Cli_Nom" & _
              ") values " & _
              "('" & M_Ces_Nom & "'" & _
              ")"
            objbanco.executar_comando(sql)
        Catch ex As Exception
            MsgBox("Ocorreu o erro: " & ex.Message, MsgBoxStyle.Critical)
            objbanco.fechar_banco()
        End Try
    End Sub
    Public Function excluir(ByVal minhacesta As Integer) As Boolean
        sql = "delete from Cestas where Ces_ID=" & minhacesta
        objbanco.executar_comando(sql)
        Return True
    End Function
    Public Function LocalizarPorID(ByVal digiteID As Integer) As DataTable
        sql = "select * from Cestas where Ces_ID = " & digiteID
        Dim objda As New OleDb.OleDbDataAdapter(sql, objbanco.objcon)
        Dim objds As New DataSet
        objda.Fill(objds)
        Return objds.Tables(0)
    End Function
End Class
